<?php
require('../../../wp-load.php');
$html = "";
$html .= "<ul>";
if($_POST["category"] == "servicios"){
	
	$curr_cat = get_category_by_slug( $_POST["category"] );
	$args_h=array(
			'parent'      => $curr_cat->term_id
			);
	$cat_h =get_categories($args_h);
	foreach($cat_h as $category_h) { 
		 $html .= "<li><a href='javascript:void(0)' rel='". $category_h->slug ."' class='sub-cat-portafolio'>". $category_h->name ."</a></li>";
	}
	
}else{
	$curr_cat = get_category_by_slug( $_POST["category"] );
	$the_query = new WP_Query(array('cat'=>$curr_cat->term_id));
	while ( $the_query->have_posts() ) :
			$the_query->the_post();	
			$post_categories = wp_get_post_categories($the_query->post->ID);
			$cats = array();

			foreach($post_categories as $c) {
					$cat = get_category($c); if($cat->cat_ID != $curr_cat) $cats[] = $cat->slug;
			}

			$html .= "<li>";
					$html .= "<div><a href='".get_permalink()."'>". get_the_title() ."</a></div>";

			$html .= "</li>";
	endwhile; 

}
$html .= "</ul>";
echo $html;
?>